//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;
using OpenLS.Drawing.Internals;

namespace OpenLS.Drawing
{
    public class Point2D : IOfficeXmlSerializableAs
    {
        private double x;

        private double y;

        public double X
        {
            get { return x; }
            set { x = value; }
        }

        public double Y
        {
            get { return y; }
            set { y = value; }
        }

        #region IOfficeXmlSerializableAs Members

        void IOfficeXmlSerializableAs.ReadXmlAs(string name, ReadContext context)
        {
            using (var c = context.Read(name))
            {
                X = EmuConverter.FromEmu(c.GetInteger64("x"));
                Y = EmuConverter.FromEmu(c.GetInteger64("y"));
            }
        }

        //\\double factor = 0.5;

        void IOfficeXmlSerializableAs.WriteXmlAs(string name, WriteContext context)
        {
            using (WriteContext c = context.Write(name))
            {
                c.SetInteger64("x", EmuConverter.ToEmu(X));
                c.SetInteger64("y", EmuConverter.ToEmu(Y));
            }
        }

        #endregion
    }
}